package com.yun.zf.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yun.zf.app.mapper.SysDocumentsMapper;
import com.yun.zf.app.service.SysDocumentsService;
import com.yun.zf.common.admin.domain.SysDocuments;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 文案信息表 服务实现类
 * </p>
 *
 * @author cj
 * @since 2021-06-16
 */
@Service
public class SysDocumentsServiceImpl extends ServiceImpl<SysDocumentsMapper, SysDocuments> implements SysDocumentsService {

    @Override
    public Map<String, List<SysDocuments>> getDocumentsByTheme(String themeid,int  platformId) {
        QueryWrapper<SysDocuments> documentsQueryWrapper = new QueryWrapper<>();
         documentsQueryWrapper.lambda().eq(SysDocuments::getStatus,0).eq(SysDocuments::getThemeId,themeid).eq(SysDocuments::getPlatformId,platformId)
         .orderByAsc(SysDocuments::getSortNum);
         List<SysDocuments> documents = baseMapper.selectList(documentsQueryWrapper);
        return  documents.stream().collect(Collectors.groupingBy(SysDocuments::getPosIndex));
    }
}
